<template>
  <div>
    <el-dialog :visible.sync="infocardshow" title="人员基础信息卡" width="90%">
      <el-main style="margin-top: -20px">
  
      </el-main>
      <work-user-info-edit
        :form="form"
        :eduexp="eduexp"
        :workexp="workexp"
        :dingtalkdeplist="dingtalkdeplist"
        :editinfo="editinfo"
        :family="family"
        :type="type"
      ></work-user-info-edit>
    </el-dialog>

  </div>
</template>

<script>
import fileupload from "../common/fileupload.vue";
import WorkUserInfoEdit from "./WorkUserInfoEdit.vue";

import RemoteSelectUser from "../common/RemoteSelectUser.vue";
import ResignIndex from "../Resign/ResignIndex.vue";

export default {
  components: { fileupload, WorkUserInfoEdit, RemoteSelectUser, ResignIndex },
  props: ["selectdepartment"],

  created() {
    this.$bus.$on("getUserDetail", (row) => {
      this.infocardshow = true;
      this.getUserDetail(row);
    });
    this.getpost();
    // this.$refs.rsu.postvalue = this.form.userid;
  },

  data() {
    return {
      sendtype: { label: "发送本人", value: 1 },
      rsustyles: {
        width: "100%",
      },

      dingtalkdeplist: [],

      changepostform: {
        id: "",
        post: "",
        depid: "",
        type: "",
        date: "",
        bz: "",
      },
      rules: {
        post: [{ required: true, message: "请选择新职位", trigger: "change" }],
        date: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        type: [
          {
            required: true,
            message: "请选择调岗类型",
            trigger: "change",
          },
        ],
        depid: [
          {
            required: true,
            message: "请调入部门",
            trigger: "change",
          },
        ],
      },

      fileList: [],

      selectpost: [],

      changepost: false,
      resgin: false,

      infocardshow: false,
      type: 1,

      editinfo: true,
      userid:"",
      form: {},
      eduexp: [],
      workexp: [],
      family: [],

      eduaddcard: false,
      workaddcard: false,

      typeoptions: [
        {
          value: "0",
          label: "晋升",
        },
        {
          value: "1",
          label: "降职",
          disabled: true,
        },
        {
          value: "2",
          label: "部门变更",
        },
        {
          value: "3",
          label: "岗位变更",
        },
      ],
    };
  },

  methods: {
    sendresigninput() {},
    changeseleect(item) {
      this.sendtype.value = item;
      console.log(this.sendtype.value);
    },

    async getpost() {
      this.$axios
        .post("api/member/getpost")
        .then((response) => {
          this.selectpost = response.data;
          console.log(response);
        })

        .catch(function (error) {
          console.log(error);
        });
    },

    cancelchangepost() {
      this.$refs.fileupload.cleanfilelist();
      this.changepost = false;
      this.changepostform = {
        id: "",
        post: "",
        depid: "",
        type: "",
        date: "",
        bz: "",
      };
    },

    sendresigntalkinput() {
      this.$confirm("此操作将向用户发送离职访谈表, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let datas = {
            userid: [this.form.userid],
            postid: sessionStorage.getItem("id"),
          };
          
          this.$axios
            .post("api/resign/sendresigntalkinput", datas)
            .then((response) => {
              this.$notify({
                title: "离职访谈",
                message: "提交成功",
                type: "success",
                duration: 1500,
              });
            })
            .catch(function (error) {
              console.log(error);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },

    sendtoother() {
      this.$confirm("此操作将向用户发送离职访谈表, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let datas = {
            leaderid:this.$refs.rsu2.userid,
            userid: this.form.id,
            postid: sessionStorage.getItem("id"),
          };
        
          this.$axios
            .post("api/resign/sendtoother", datas)
            .then((response) => {
              this.$notify({
                title: "离职访谈",
                message: "提交成功",
                type: "success",
                duration: 1500,
              });
            })
            .catch(function (error) {
              console.log(error);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },



    sendchangepost(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let datas = {
            form: this.changepostform,
            posterid: sessionStorage.getItem("userid"),
            userid: this.form.userid,
            fileinfo: this.$refs.fileupload.fileinfo,
          };
          console.log(datas)
          this.$axios
            .post("api/member/sendchangepost", datas)
            .then((response) => {
              this.$notify({
                title: "用户信息",
                message: response.data,
                type: "success",
                duration: 1500,
              });
              this.cancelchangepost();
            })
            .catch(function (error) {
              console.log(error);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    async getUserDetail(row) {
      let id = row.id;
      try {
        let res = await this.$axios.get(`api/member/getuserdetail?id=` + id);
        this.form = res.data.member[0];
        this.eduexp = res.data.eduexp;
        this.workexp = res.data.workexp;
        this.dingtalkdeplist = res.data.dingtalkdeplist;
        this.family = res.data.family;
        this.userid=res.data.member[0].id;
        console.log(res)
        // this.$refs.rsu2.postvalue
        // this.$refs.rsu.setuser(this.form.userid);
      } catch (e) {}
    },
  },
};
</script>

<style>
</style>